package com.punai.common.utils.sqliteConne;

import com.punai.common.utils.sqlite.SqliteUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "standard")
public class StandardUserTemplConnection {
    private static final Logger log = LoggerFactory.getLogger(StandardUserTemplConnection.class);

    private SqliteUtil sqliteUtil;

    private String userTempl;

    public String getUserTempl() {
        return userTempl;
    }

    public void setUserTempl(String userTempl) {
        this.userTempl = userTempl;
    }

    public SqliteUtil initConnection() {
        log.warn("sqliteUtil创建链接");
        log.warn("sqliteUtil:"+ sqliteUtil);
        if (sqliteUtil == null) {
            log.warn("sqliteUtil为空，new SqliteUtil()");
            sqliteUtil= new SqliteUtil();
            sqliteUtil.getConnection(userTempl);
        }
        log.warn("userTempl路径：" + userTempl);
        log.warn("sqliteUtil创建链接成功返回："+sqliteUtil);
        return sqliteUtil;
    }

    public SqliteUtil getSqliteUtil() {
        return sqliteUtil;
    }
}
